/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('intelligentcreation', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model CreateLabelTaskRequest {
  fileUrl?: string(name='fileUrl', example='oss://test/test'),
  idempotentId?: string(name='idempotentId', example='7caa09aa60204086909ba3958810a567'),
  labelTemplateId?: string(name='labelTemplateId', example='1_for_7_label_v1'),
}

model CreateLabelTaskResponseBody = {
  errorCode?: string(name='errorCode', example='PARAM_ERROR'),
  errorMessage?: string(name='errorMessage'),
  requestId?: string(name='requestId', example='56AC346B-AF40-5E4F-AFFE-FD8BA5E6FB3A'),
  success?: boolean(name='success', example='true'),
  taskId?: string(name='taskId', example='829682927337963520'),
}

model CreateLabelTaskResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CreateLabelTaskResponseBody(name='body'),
}

/**
 * @summary 创建模型标注任务
 *
 * @param request CreateLabelTaskRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return CreateLabelTaskResponse
 */
async function createLabelTaskWithOptions(request: CreateLabelTaskRequest, headers: map[string]string, runtime: Util.RuntimeOptions): CreateLabelTaskResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.fileUrl)) {
    body['fileUrl'] = request.fileUrl;
  }
  if (!Util.isUnset(request.idempotentId)) {
    body['idempotentId'] = request.idempotentId;
  }
  if (!Util.isUnset(request.labelTemplateId)) {
    body['labelTemplateId'] = request.labelTemplateId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'CreateLabelTask',
    version = '2024-11-07',
    protocol = 'HTTPS',
    pathname = `/yic/yic-console/openService/v1/aitag/createLabelTask`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 创建模型标注任务
 *
 * @param request CreateLabelTaskRequest
 * @return CreateLabelTaskResponse
 */
async function createLabelTask(request: CreateLabelTaskRequest): CreateLabelTaskResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return createLabelTaskWithOptions(request, headers, runtime);
}

model GetLabelTaskResultRequest {
  taskId?: string(name='taskId', example='313123123'),
}

model GetLabelTaskResultResponseBody = {
  message?: string(name='message', example='ok'),
  requestId?: string(name='requestId', example='D5798660-1531-5D12-9C20-16FEE9D22351'),
  resultDataUrl?: string(name='resultDataUrl', example='https://yic-pre.oss-cn-hangzhou.aliyuncs.com/ai_tag_algo_log/1539704706413278/829593441691238400/merge_label_final_result?Expires=1732083305&OSSAccessKeyId=LTAI5tPHLyFPhh4UoRias4Zg&Signature=Am3cBxlc6hYFKtdGlw9o1R26Vsk%3D'),
  status?: string(name='status', example='SUCCESS'),
  tokens?: long(name='tokens', example='20023'),
}

model GetLabelTaskResultResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetLabelTaskResultResponseBody(name='body'),
}

/**
 * @summary 查询模型标注任务结果
 *
 * @param request GetLabelTaskResultRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetLabelTaskResultResponse
 */
async function getLabelTaskResultWithOptions(request: GetLabelTaskResultRequest, headers: map[string]string, runtime: Util.RuntimeOptions): GetLabelTaskResultResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.taskId)) {
    query['taskId'] = request.taskId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetLabelTaskResult',
    version = '2024-11-07',
    protocol = 'HTTPS',
    pathname = `/yic/yic-console/openService/v1/aitag/getLabelTask`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 查询模型标注任务结果
 *
 * @param request GetLabelTaskResultRequest
 * @return GetLabelTaskResultResponse
 */
async function getLabelTaskResult(request: GetLabelTaskResultRequest): GetLabelTaskResultResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getLabelTaskResultWithOptions(request, headers, runtime);
}

